Skip to content

feat(telemetry): add global --biz-source for per-source PV/UV attribution (prepare 2.11.0) - #335

Merged
lishengzxc merged 2 commits into
mainfrom
feat/global-biz-source
Nov 24, 2026
Merged

lishengzxc merged 2 commits into
mainfrom
feat/global-biz-source

Conversation

@lishengzxc

Copy link
Copy Markdown
Contributor

Summary

Add a unified, global --biz-source <source> flag (flag key bizSource) available on all commands, so callers (skills / agents / products) can declare their business source. The value is reported through the telemetry module to enable per-source PV/UV analysis of command usage (including flow-agent).

Design

  • Global flag: added to GLOBAL_FLAGS (packages/core/src/types/command.ts), so every command accepts --biz-source and it appears in global help / introspect. Description encourages skills/callers to pass their own name for attribution.
  • Settings: Settings.bizSource (config/schema.ts) + buildSettings mapping (config/loader.ts, flags.bizSource ?? undefined — explicit empty string preserved, not folded). Per-invocation only, not persisted.
  • Normalization: normalizeBizSource (telemetry/caller.ts) reuses the caller NAME_PATTERN (lowercase, spaces/underscores→dashes, bounded charset) to prevent PII. Absent → omitted; blank/invalid → "unknown".
  • Reporting: tracker.ts reads deps.settings.bizSource (no middleware change) → createTrackingEvent sets TrackingEvent.bizSource (goes to AEM ext + local JSONL). buildRemoteAemOptions additionally maps it to a dedicated flat column c6 (scalar string) for direct AEM filtering/grouping without JSON-parse dimension config. Not added to PARAM_ALLOWLIST (c1). c1–c5 already occupied; c6 free.
  • PV/UV: group by c6 (bizSource): PV = event count, UV = distinct uid; filter by command path (e.g. flow-agent *) for per-group source breakdown. Independent of callerType/callerName.

Tests

  • core/tests/telemetry-tracker.test.ts: bizSource → event/ext/c6; normalization (valid/underscore/invalid/blank/empty); absent omits field+c6.
  • core/tests/telemetry-caller.test.ts: normalizeBizSource unit cases.
  • core/tests/config-priority.test.ts: flag→settings mapping incl. empty-string preservation.
  • cli/tests/e2e/registry.smoke.e2e.test.ts: global help includes --biz-source.
  • End-to-end verified: real config show --biz-source Coze writes "bizSource":"coze" to local telemetry.jsonl.

Docs

  • docs/agents/telemetry-change.md: TrackingEvent field list + AEM mapping table (c6), normalization, PV/UV semantics.
  • sync:skill-assets regenerated skill reference (new flag row + table column-width realignment).

Verification

  • pnpm run check: 0 errors.
  • core tests 94 passed; cli registry.smoke 491 passed.
  • Code review passed (1 minor fixed: ||→?? for explicit empty string).

…tion

Global flag bizSource on all commands; buildSettings maps it into settings, tracker normalizes (NAME_PATTERN, blank/invalid->unknown) and reports TrackingEvent.bizSource to AEM ext plus dedicated flat column c6 for direct filtering. PV=event count, UV=distinct uid, segment by c6 + command path. Adds core/e2e tests and telemetry-change doc; regenerates skill reference.
Bump seven packages 2.10.5 -> 2.11.0; add bilingual CHANGELOG entry for the global --biz-source telemetry flag; sync SKILL metadata.
@lishengzxc lishengzxc changed the title feat(telemetry): add global --biz-source for per-source PV/UV attribution feat(telemetry): add global --biz-source for per-source PV/UV attribution (prepare 2.11.0) Nov 24, 2026
@lishengzxc
lishengzxc merged commit 150b70a into main Nov 24, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant